package com.alks.function.controller.biocontrol.deptwork;

import com.alks.common.aop.ApiRestController;
import com.alks.common.aop.RoleCheck;
import com.alks.entity.data.entity.CpBaseDetail;
import com.alks.entity.data.entity.CpBaseHead;
import com.alks.entity.data.response.ResponseInfo;
import com.alks.function.service.biocontrol.deptwork.ICpBaseService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

@RestController
@ApiRestController("/bioDeptWrok")
@Api(value = "生控作业", tags = "生控部-生控作业-制具资料设定")
@RequiredArgsConstructor
@RoleCheck(prgIds = "140115")
public class CpBaseController {
    private final ICpBaseService service;

    @GetMapping("/getCpBaseHeadQuery")
    @ApiOperation(value = "代码类型查询-可条件查询", tags = "生控部-生控作业-制具资料设定")
    public ResponseInfo getCpBaseHeadQuery() {
        return service.getCpBaseHeadQuery();
    }

    @PutMapping("/cpBaseHeadUpdate")
    @ApiOperation(value = "代码类型更新-更新", tags = "生控部-生控作业-制具资料设定")
    public ResponseInfo cpBaseHeadUpdate(@RequestBody CpBaseHead request,
                                         @RequestParam String baseTypeOld) {
        return service.cpBaseHeadUpdate(request,baseTypeOld);
    }

    @PutMapping("/cpBaseHeadAdd")
    @ApiOperation(value = "代码类型新增-新增", tags = "生控部-生控作业-制具资料设定")
    public ResponseInfo cpBaseHeadAdd(@RequestBody CpBaseHead request) {
        return service.cpBaseHeadAdd(request);
    }

    @PutMapping("/cpBaseHeadDelete")
    @ApiOperation(value = "代码类型删除-删除", tags = "生控部-生控作业-制具资料设定")
    public ResponseInfo cpBaseHeadDelete(@RequestParam@ApiParam("类型代码") String baseType) {
        return service.cpBaseHeadDelete(baseType);
    }

    @GetMapping("/getCpBaseDetQuery")
    @ApiOperation(value = "类型明细查询-可条件查询", tags = "生控部-生控作业-制具资料设定")
    public ResponseInfo getCpBaseDetQuery(@RequestParam@ApiParam("类型代码") String baseType) {
        return service.getCpBaseDetQuery(baseType);
    }

    @PutMapping("/cpBaseDetUpdate")
    @ApiOperation(value = "类型明细更新-更新", tags = "生控部-生控作业-制具资料设定")
    public ResponseInfo cpBaseDetUpdate(@RequestBody CpBaseDetail request,
                                        @RequestParam@ApiParam("类型代码") String baseTypeOld,
                                        @RequestParam@ApiParam("代码") String itemCodeOld) {
        return service.cpBaseDetUpdate(request,baseTypeOld,itemCodeOld);
    }

    @PutMapping("/cpBaseDetAdd")
    @ApiOperation(value = "类型明细新增-新增", tags = "生控部-生控作业-制具资料设定")
    public ResponseInfo cpBaseDetAdd(@RequestBody CpBaseDetail request) {
        return service.cpBaseDetAdd(request);
    }

    @PutMapping("/cpBaseDetDelete")
    @ApiOperation(value = "类型明细删除-删除", tags = "生控部-生控作业-制具资料设定")
    public ResponseInfo cpBaseDetDelete(@RequestParam String baseType,
                                        @RequestParam String itemCode) {
        return service.cpBaseDetDelete(baseType,itemCode);
    }


}
